package 编程能力入门1;

public class _07数组元素积的符号 {
    public static int arraySign(int[] nums) {
        if(nums == null || nums.length == 0) return 0;
        boolean flag = false; //标志位，默认位true
        for (int num : nums) {
            if(num == 0){
                return 0;
            }
            if(num<0){
                flag = !flag;
            }
        }
        return flag ? -1 : 1;
    }

    public static void main(String[] args) {
        int[] array = {41,65,14,80,20,10,55,58,24,56,28,86,96,10,3,84,4,41,13,32,42,43,83,78,82,70,15,-41};
        System.out.println(arraySign(array));
    }
}
